package 力扣日常刷题.木22二月.第17天223;

/**
 * @author 帅小伙
 * @date 2022/2/23
 * @description
 */
public class Demo144买汽水 {


    public int solution(int n) {
        int ans = 0;
        int buyNum = n / 2;
        int bottle = buyNum / 2,lid = buyNum / 4;
        ans  = buyNum + bottle + lid;

        while (lid!= 0 && bottle != 0) {
            bottle = (lid + bottle) / 2;
            lid = (bottle + lid) / 4;
            ans = ans + bottle +lid;
        }
        return ans;
    }

}
